//
//  BuyCountView.m
//  AddShoppingCartDemo
//
//  Created by Jim1024 on 2016/12/23.
//  Copyright © 2016年 Jim1024. All rights reserved.
//

#import "BuyCountView.h"

@implementation BuyCountView

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        _textLb = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 100, 30)];
        _textLb.text = @"购买数量";
        _textLb.textColor = [UIColor blackColor];
        _textLb.font = [UIFont systemFontOfSize:14];
        [self addSubview:_textLb];
        
        _addBtn= [UIButton buttonWithType:UIButtonTypeCustom];
        _addBtn.frame = CGRectMake(self.frame.size.width-10-40, 10,40, 30);
        [_addBtn setBackgroundColor:[UIColor colorWithRed:240/255.0 green:240/255.0 blue:240/255.0 alpha:1]];
        [_addBtn setTitleColor:[UIColor blackColor] forState:0];
        _addBtn.titleLabel.font = [UIFont systemFontOfSize:20];
        [_addBtn setTitle:@"+" forState:0];
        [self addSubview:_addBtn];
        
        _countTf = [[UITextField alloc] initWithFrame:CGRectMake(_addBtn.frame.origin.x - 45, 10, 40, 30)];
        _countTf.text = @"1";
        _countTf.textAlignment = NSTextAlignmentCenter;
        _countTf.font = [UIFont systemFontOfSize:15];
        _countTf.backgroundColor = [UIColor colorWithRed:240/255.0 green:240/255.0 blue:240/255.0 alpha:1];
        [self addSubview:_countTf];
        
        _reduceBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _reduceBtn.frame = CGRectMake(_countTf.frame.origin.x - 45, 10, 40, 30);
        [_reduceBtn setBackgroundColor:[UIColor colorWithRed:240/255.0 green:240/255.0 blue:240/255.0 alpha:1]];
        [_reduceBtn setTitleColor:[UIColor blackColor] forState:0];
        _reduceBtn.titleLabel.font = [UIFont systemFontOfSize:20];
        [_reduceBtn setTitle:@"-" forState:0];
        [self addSubview:_reduceBtn];
        
        UILabel *line = [[UILabel alloc] initWithFrame:CGRectMake(0, self.frame.size.height-0.5, self.frame.size.width, 0.5)];
        line.backgroundColor = [UIColor lightGrayColor];
        [self addSubview:line];
    }
    return self;
}

@end
